package com.xdcplus.web.controller;



import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.exceptions.domain.ResponseVO;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.ToolProductionLineToolDTO;
import com.xdcplus.web.common.pojo.dto.ToolProductionLineToolFilterDTO;
import com.xdcplus.web.common.pojo.vo.ToolProductionLineToolVO;
import com.xdcplus.web.service.ToolProductionLineToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * (ToolProductionLineTool)表服务控制层
 *
 * @author Man.Chen
 * @since 2024-12-03 16:41:13
 */
@Api(tags = "(ToolProductionLineTool)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("toolProductionLineTool")
public class ToolProductionLineToolController extends AbstractController {

    @Autowired
    private ToolProductionLineToolService toolProductionLineToolService;

    @ApiOperation("新增")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO saveToolProductionLineTool(@RequestBody ToolProductionLineToolDTO toolProductionLineToolDTO) {

        log.info("saveToolProductionLineTool {}", toolProductionLineToolDTO.toString());

        toolProductionLineToolDTO.setCreatedUser(getAccount());
        toolProductionLineToolService.saveToolProductionLineTool(toolProductionLineToolDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO updateToolProductionLineTool(@RequestBody ToolProductionLineToolDTO toolProductionLineToolDTO) {

        log.info("updateToolProductionLineTool {}", toolProductionLineToolDTO.toString());

        toolProductionLineToolDTO.setUpdatedUser(getAccount());
        toolProductionLineToolService.updateToolProductionLineTool(toolProductionLineToolDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除")
    @DeleteMapping(value = "/{toolProductionLineToolId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "toolProductionLineToolId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO deleteToolProductionLineToolLogical(@PathVariable("toolProductionLineToolId")
                                         @NotNull(message = "ID不能为空") Long toolProductionLineToolId) {

        log.info("deleteToolProductionLineToolLogical {}", toolProductionLineToolId);

        toolProductionLineToolService.deleteToolProductionLineToolLogical(toolProductionLineToolId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除")
    @DeleteMapping(value = "/deleteByIds/{toolProductionLineToolIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "toolProductionLineToolId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO deleteToolProductionLineToolLogical(@PathVariable("toolProductionLineToolIds")
                                         @NotNull(message = "ID不能为空") String toolProductionLineToolIds) {

        log.info("deleteToolProductionLineToolByIds {}", toolProductionLineToolIds);

        toolProductionLineToolService.deleteToolProductionLineToolByIds(toolProductionLineToolIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<ToolProductionLineToolVO>> findToolProductionLineTool(ToolProductionLineToolFilterDTO toolProductionLineToolFilterDTO) {

        log.info("findToolProductionLineTool {}", toolProductionLineToolFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(toolProductionLineToolFilterDTO);

        return ResponseVO.success(toolProductionLineToolService.queryToolProductionLineTool(toolProductionLineToolFilterDTO));
    }


}
